
<!DOCTYPE html>
<html>

<head lang="en">
    <title>找攻略</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/strategyComment.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>
    <link rel="stylesheet" href="/css/common.css"/>
    <script src="/js/checkLogin.js"></script>
    <script src="/js/common.js"></script>

    <script type="text/javascript">
        $(function () {
            var usern = JSON.parse(sessionStorage.getItem('user'));
            var currentPage = 1;    // 当前页
            var pages;  // 总页数
            var commentData = [];   // 定义一个数组用来接收每次分页时的数据
            function query() {  // 记得传递当前页这个参数
                console.log("hello");
                // 根据攻略id获得其对应的评论信息
                $.get(baseUrl + "/users/{userId}/strategyComments", {
                    pageSize: 8,
                    currentPage: currentPage,
                    userId: user.id
                }, function (data) {
                    $.merge(commentData, data.list);
                    var json = {
                        list: commentData
                    };
                    $(".comment").renderValues(json, {
                        getHref: function (item, value) {
                            var url = $(item).data("href");
                            $(item).attr("href", url + value);
                        },
                        getModelState: function (item, value) {
                            $(item).attr("data-mdId", value)
                        },
                        getArticleId: function (item, value) {
                            $(item).attr("data-acId", value)
                        },
                        getStrategyId: function (item, value) {
                            $(item).attr("data-stId", value)
                        }

                    });
                    var mdId;
                    var stId;;
                    $(".userInfBtn").click(function () {
                        window.location.href = "/userProfiles.html?id=" + usern.id
                    })
                    $(".strategyChooseBtn").click(function () {
                        stId = $(this).data("stid")
                    });
                    $(".articleSkipBtnHidden").click(function () {
                        mdId = $(this).data("mdid");
                        $(this).next().click();
                    });

                    $(".articleSkipBtn").click(function () {
                        $(this).next().click();
                        var acId = $(this).data("acid");
                        if (mdId == 0) {
                            window.location.href = "/travelContent.html?id=" + acId;
                        }
                        if (mdId == 1) {
                            $(this).prev().click();
                            window.location.href = "/mine/strategyComment.html?id=" + acId + "&hid=" + stId;
                        }
                        if (mdId == 2) {
                            window.location.href = "/mine/dailyNewsComment.html?id=" + acId;
                        }
                        if (mdId == 3) {
                            window.location.href = "/strategyDetails.html?id=" + acId;
                        }
                    })
                    $(".articleFormBtn").click(function () {
                        mdId = $(this).data("mdid")
                        if (mdId == 0) {
                            window.location.href = "/travelPage.html";
                        }
                        if (mdId == 1) {
                            $(this).prev().click();
                            window.location.href = "/strategyPage.html";
                        }
                        if (mdId == 2) {
                            window.location.href = "/newsPage.html";
                        }
                        if (mdId == 3) {
                            window.location.href = "/strategyPage.html";
                        }
                    })
                    pages = data.pages;
                });
                currentPage++;
            }

            query();
            // 监听滚动事件,当滚动条发生变化时触发
            $(window).scroll(function () {
                // document滚上去的高度+手机窗口的高度 >= 整个文档的高度
                if (($(document).scrollTop() + $(window).height()) >= $(document).height() - 1) {
                    if (currentPage <= pages) { // 如果当前页数小于等于总页数
                        query();
                    } else {
                        $(document).dialog({
                            type: 'notice',
                            content: '<span class="info-text">我是有底线的!</span>',
                            autoClose: 1000,
                            position: 'bottom'
                        });
                    }
                }
            });
        })
    </script>
</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:history.go(-1);" style="position: absolute;top: 3px;left: 22px;">
                <span><i class="fa fa-chevron-left fa-2x" style="color: white;"></i></span>
            </a>
        </div>
        <div class="col">
            <span>点评详情</span>
        </div>
        <div class="col"></div>
    </div>
</div>

<div class="comment">
    <div render-loop="list">
        <div class="container" id="containerBtn">
            <div class="row">
                <div class="col-2 comment-head">
                    <a>
                        <img class="rounded-circle userInfBtn" render-src="list.user.headImgUrl">
                    </a>
                </div>
                <div class="col">
                    <a style="font-size: 10px;color: #61CAD0" render-html="list.user.nickName"></a>
                    <span class="comment-date" render-html="list.creatime"></span>
                    <div class="comment-content">
                        <p render-html="list.content"></p>
                    </div>
                    <div>
                        <span style="color: #28a745">所属回答:
                            <input type="hidden" render-key="list.strategy.id" render-fun="getStrategyId"
                                   class="strategyChooseBtn">
                            <a render-html="list.strategy.title"
                               render-key="list.strategy.id"
                               render-fun="getArticleId" class="articleSkipBtn">
                        </a>
                            <input type="hidden" render-key="list.modelState" render-fun="getModelState"
                                   class="articleSkipBtnHidden">
                        </span>
                    </div>
                </div>
            </div>
            <div class="count d-flex justify-content-between">
            </div>
        </div>
    </div>
</div>
</div>
</body>
</html>